<html lang="en">
<head>
    <script src="/static/jquery-1.11.0.min.js"></script>
    <script src="/static/sockjs-0.3.min.js"></script>

    <link href="/static/mycss.css" rel="stylesheet" type="text/css"/>

    <meta charset="UTF-8"/>
    <title>Sock chat</title>
    <style type="text/css">


        body, div, ul, li {

            margin: 0 auto;

            padding: 0;

        }

        body {

            font: 12px "宋体";

            text-align: center;

        }

        a:link {

            color: #00F;

            text-decoration: none;

        }

        a:visited {

            color: #00F;

            text-decoration: none;

        }

        a:hover {

            color: #c00;

            text-decoration: underline;

        }

        ul {

            list-style: none;

        }

        .main {

            clear: both;

            padding: 8px;

            text-align: center;

        }

        #tabs0 {

            height: 950px;

            width: 1800px;

            border: 1px solid #cbcbcb;

            background-color: #f2f6fb;

        }

        .menu0 {

            width: 2300px;

        }

        .menu0 li {

            display: block;

            float: left;

            padding: 7px 0;

            width: 150px;

            text-align: center;

            cursor: pointer;

            background: #FFFFff;

        }

        .menu0 li.hover {

            background: #f2f6fb;

        }

        #main0 ul {

            display: none;

        }

        #main0 ul.block {

            display: block;

        }

    </style>
    <script>
        var sock = new SockJS('http://localhost:5000/echo');
        // Open the connection
        sock.onopen = function () {
            document.getElementById('div_echo').innerHTML = 'open';
        };

        // On connection close
        sock.onclose = function () {
            document.getElementById('div_echo').innerHTML = 'open';
        };

        // On receive message from server
        sock.onmessage = function (e) {
            console.log(e);
            document.getElementById('div_echo').innerHTML = e.data;
        };

        function echo(){
            sock.send('form webbrower');
            console.log(sock);
        }

    </script>
</head>
<body>

输入：
<input id='echo' type='text'/>
<button onclick="echo()">确定</button>
<div id='div_echo'>输出</div>

</body>
</html>
